<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>客户详情</title>
<link href="${rc.contextPath}/assets/css/bootstrap.min.css"
	rel="stylesheet" />
	
<link rel="stylesheet"
	href="${rc.contextPath}/assets/css/font-awesome.min.css" />
<link rel="stylesheet"
	href="${rc.contextPath}/assets/css/datepicker.css" />
<link rel="stylesheet" href="${rc.contextPath}/assets/css/ui.jqgrid.css" />

<link rel="stylesheet"
	href="${rc.contextPath}/assets/css/jquery-ui-1.10.3.full.min.css" />
<link rel="stylesheet" href="${rc.contextPath}/assets/css/ace.min.css" />
<!-- ace settings handler -->
<script src='${rc.contextPath}/assets/js/jquery-2.0.3.min.js'></script>
<script src="${rc.contextPath}/assets/js/bootstrap.min.js"></script>
<!-- page specific plugin scripts -->

<script src="${rc.contextPath}/assets/js/jquery-ui-1.10.3.full.min.js"></script>
<script src="${rc.contextPath}/assets/js/jqGrid/jquery.jqGrid.min.js"></script>
<script src="${rc.contextPath}/assets/js/jqGrid/i18n/grid.locale-en.js"></script>
<!-- ace scripts -->
<script src="${rc.contextPath}/assets/js/date-time/bootstrap-datepicker.min.js"></script>
<script src="${rc.contextPath}/assets/js/date-time/bootstrap-datetimepicker.js"></script>
<script src="${rc.contextPath}/assets/js/ace-extra.min.js"></script>
<script src="${rc.contextPath}/common/js/common.js"></script>
<script src="${rc.contextPath}/common/js/thickbox/thickbox.js"></script>
<script src="${rc.contextPath}/common/js/config.js"></script>
<script
	src="${rc.contextPath}/common/js/market/customer/customer_details.js"></script>

<script src="${rc.contextPath}/assets/js/jquery.slimscroll.min.js"></script>
<script src="${rc.contextPath}/assets/js/jquery.easy-pie-chart.min.js"></script>
<script src="${rc.contextPath}/assets/js/jquery.sparkline.min.js"></script>
<script src="${rc.contextPath}/assets/js/flot/jquery.flot.min.js"></script>
<script src="${rc.contextPath}/assets/js/flot/jquery.flot.pie.min.js"></script>
<script src="${rc.contextPath}/assets/js/flot/jquery.flot.resize.min.js"></script>
<script src="${rc.contextPath}/assets/js/ace-extra.min.js"></script>
<script src="${rc.contextPath}/assets/js/ace-elements.min.js"></script>
<script src="${rc.contextPath}/assets/js/ace.min.js"></script>
<script src="${rc.contextPath}/assets/js/bootbox.min.js"></script>
<script src="${rc.contextPath}/assets/js/jquery.validate.min.js"></script>
<!-- <script type="text/javascript" src="${rc.contextPath}common/js/market/customer/service_customer.js"></script> -->
</head>
<body>
	<div class="main-container">
		<div class="page-content">

			<div class="page-header">
				当前位置 <i class="icon-double-angle-right"></i> 客户管理 <small> <i
					class="icon-double-angle-right"></i> 客户详情
				</small>
				<p style="float: right">姓名： $!{currentUser.ename}</p>
			</div>
			<div id="dialog" class="hide">
			</div>
			<div class="row">
				<div class="col-sm-8">

					<span style="float: left; padding-left: 50px">系统名称:</span> <span
						style="float: left; padding-left: 10px"><p
							class="text-muted">$!{customerInfo.organizeNameCN}</p></span> <span
						style="float: left; padding-left: 30px">会员号:</span> <span
						style="float: left; padding-left: 10px"><p
							class="text-muted">$!{customId}</p></span> <span
						style="float: left; padding-left: 30px">余额:</span> <span
						style="float: left; padding-left: 10px"><p id="balance"
							class="text-muted">$!{customerInfo.balance}</p></span> <span
						style="float: left; padding-left: 5px"> <a href="javascript:refreshBalance()"
						title="刷新余额"><i class="icon-refresh bigger-110 red"></i></a>
				</div>

				<div class="col-sm-4">

					<i class="icon-hand-right icon-animated-hand-pointer blue"></i> <a
						href="#customView" role="button" class="blue" data-toggle="modal">
						查看会员系统详细信息 </a>
					<div id="customView" class="modal fade" tabindex="-1">
						<div class="modal-dialog" style="width: 400px;">
							<div class="modal-content">
								<div class="modal-header no-padding">
									<div class="table-header">
										<button type="button" class="close" data-dismiss="modal"
											aria-hidden="true">
											<span class="white">&times;</span>
										</button>
										会员详细信息
									</div>
								</div>

								<div class="modal-body no-padding">
									<table
										class="table table-striped table-bordered table-hover no-margin-bottom no-border-top">

										<tbody>
											<tr>
												<td><a href="#">注册渠道：</a></td>
												<td>官网注册</td>
											</tr>

											<tr>
												<td><a href="#">会员编号：</a></td>
												<td>$!{customId}</td>
											</tr>

											<tr>
												<td><a href="#">单位名称（个人姓名）：</a></td>
												<td>$!{customerInfo.organizeNameCN}</td>
											</tr>

											<tr>
												<td><a href="#">所属区域：</a></td>
												<td>$!{customerInfo.areaName}</td>
											</tr>

											<tr>
												<td><a href="#">通讯地址:</a></td>
												<td>$!{customerInfo.publicStreetCN}</td>
											</tr>

											<tr>
												<td><a href="#">邮政编码：</a></td>
												<td>$!{customerInfo.publicZipCode}</td>
											</tr>

											<tr>
												<td><a href="#">手机号码：</a></td>
												<td>$!{customerInfo.phone}</td>
											</tr>

											<tr>
												<td><a href="#">电话号码：</a></td>
												<td>$!{customerInfo.userPhoneNumber}</td>
											</tr>

											<tr>
												<td><a href="#">传真号码：</a></td>
												<td>$!{customerInfo.userFaxNumber}</td>
											</tr>

											<tr>
												<td><a href="#">联系人：</a></td>
												<td>$!{customerInfo.cname}</td>
											</tr>

											<tr>
												<td><a href="#">联系邮箱账号：</a></td>
												<td>$!{customerInfo.email}</td>
											</tr>

											<tr>
												<td><a href="#">绑定邮箱账号：</a></td>
												<td>$!{customerInfo.email}</td>
											</tr>

											<tr>
												<td><a href="#">注册日期 ：</a></td>
												<td>$!{customerInfo.addTime}</td>
											</tr>
										</tbody>
									</table>
								</div>
							</div>
							<!-- /.modal-content -->
						</div>
						<!-- /.modal-dialog -->
					</div>
					
								
					
				</div>
			</div>

			<div id="tabs">
				<ul>
					<li><a href="#tabs-1"><span class="text-primary">基本信息</span></a>
					</li>

					<li><a href="#tabs-2" onclick="createTable(2)"><span
							class="text-primary">商品信息</span></a></li>
					<li><a href="#tabs-3" onclick="createTable(3)"><span
							class="text-primary">订单信息</span></a></li>
					<li><a href="#tabs-4" onclick="createTable(4)"><span
							class="text-primary">沟通记录</span></a></li>
					<li><a href="#tabs-5" onclick="createTable(5)"><span
							class="text-primary">购物车信息</span></a></li>
				</ul>

				<div id="tabs-1" class="col-xs-12">
					<div class="widget-box">
						<div class="widget-header widget-header-blue widget-header-flat">
							<h4 class="lighter">会员信息管理</h4>

							<div class="widget-toolbar">
								<label> <small class="green"> <b>编辑</b>
								</small> <input id="skip-validation" type="checkbox"
									class="ace ace-switch ace-switch-4" /> <span class="lbl"></span>
								</label>
							</div>
						</div>
						<div class="widget-body">
							<div class="widget-main">
								<form class="form-horizontal hide" id="validation-form"
									method="post" action="${rc.contextPath}/contact/addContact">
									<div class="form-group">
										<label
											class="control-label col-xs-12 col-sm-1 no-padding-right"
											for="reportName">企业名称</label>
										<input type="hidden" name="cusId" value="$!{customId}"
													class="col-xs-12 col-sm-6" />
										<div class="col-xs-12 col-sm-9">
											<div class="clearfix">
												<input type="text" name="uname" id="uname" value="$!{customerContact.uname}"
													class="col-xs-12 col-sm-6" />
											</div>
										</div>
									</div>

									<div class="form-group">
										<label
											class="control-label col-xs-12 col-sm-1 no-padding-right"
											for="cNature">客户性质</label>
										<div class="col-xs-12 col-sm-9">
											<div class="clearfix">
												<select name="cNature" id="cNature" class="input-small">
		  												#foreach($nature in $customerNatureEnmu)
			  												#if($nature.value==$!{customerContact.cNature})
			  													<option value="$nature.value" selected="selected">$nature.label</option>
			  												
			  												#else
									  						<option value="$nature.value">$nature.label</option>
									  						#end
									  					#end
												</select>
											</div>
										</div>
									</div>

									<div class="form-group">
										<label
											class="control-label col-xs-12 col-sm-1 no-padding-right"
											for="address">详细地址</label>
										<div class="col-xs-12 col-sm-9">
											<div class="clearfix">
												<input type="text" name="address" id="address"
													class="col-xs-12 col-sm-6" value="$!{customerContact.address}" />
											</div>
										</div>
									</div>

									<div class="form-group">
										<label
											class="control-label col-xs-12 col-sm-1 no-padding-right"
											for="email">邮箱</label>
										<div class="col-xs-12 col-sm-9">
											<div class="clearfix">
												<input type="text" name="email" id="email" value="$!{customerContact.email}"
													class="col-xs-12 col-sm-2" />
											</div>
										</div>
									</div>

									<div class="form-group">
										<label
											class="control-label col-xs-12 col-sm-1 no-padding-right"
											for="mobile">手机号</label>
										<div class="col-xs-12 col-sm-9">
											<div class="clearfix">
												<input type="text" name="mobile" id="mobile" value="$!{customerContact.mobile}"
													class="col-xs-12 col-sm-2" />
											</div>
										</div>
									</div>

									<div class="form-group">
										<label
											class="control-label col-xs-12 col-sm-1 no-padding-right"
											for="cname">联系人</label>
										<div class="col-xs-12 col-sm-9">
											<div class="clearfix">
												<input type="text" name="cname" id="cname" value="$!{customerContact.cname}"
													class="col-xs-12 col-sm-2" />
											</div>
										</div>
									</div>

									<div class="form-group">
										<label
											class="control-label col-xs-12 col-sm-1 no-padding-right"
											for="phone">座机</label>
										<div class="col-xs-12 col-sm-9">
											<div class="clearfix">
												<input type="text" name="phone" id="phone" value="$!{customerContact.phone}"
													class="col-xs-12 col-sm-2" />
											</div>
										</div>
									</div>

									<div class="form-group">
										<label
											class="control-label col-xs-12 col-sm-1 no-padding-right"
											for="remark">备注</label>
										<div class="col-xs-12 col-sm-9">
											<div class="clearfix">
												<input type="text" name="remark" id="remark" value="$!{customerContact.remark}"
													class="col-xs-12 col-sm-6" />
											</div>
										</div>
									</div>

									<div class="form-actions">
										<div class="col-md-offset-1">
											<button class="btn btn-success btn-info" type="submit">
												提交</button>
										</div>
									</div>
								</form>
								
								<!-- 会员基本信息标签页 -->
								<div id="sample-form">
									<span style="float: left; padding-left: 50px">企业名称:</span>
									<span style="float: left; padding-left: 10px">
										<p class="text-muted">&nbsp;$!{customerContact.uname}</p>
									</span> 
									<span class="clearfix"></span>
									<span style="float: left; padding-left: 50px">客户性质:</span> 
									<span style="float: left; padding-left: 10px">
										<p class="text-muted">&nbsp;$!{customerContact.cNatureStr}</p>
									</span> <span class="clearfix"></span> 
									<span style="float: left; padding-left: 50px">详细地址:</span> 
									<span style="float: left; padding-left: 10px">
									    <p class="text-muted">&nbsp;$!{customerContact.address}</p>
									</span> 
									<span class="clearfix"></span> 
									<span style="float: left; padding-left: 50px">邮箱:</span> 
									<span style="float: left; padding-left: 10px">
									<p class="text-muted">&nbsp;$!{customerContact.email}</p>
									</span> 
									<span class="clearfix"></span> 
									<span style="float: left; padding-left: 50px">手机号:</span> 
									<span style="float: left; padding-left: 10px">
										<p class="text-muted">&nbsp;$!{customerContact.mobile}</p>
									</span>  
									<span class="clearfix"></span> 
									<span style="float: left; padding-left: 50px">联系人:</span> 
									<span id = "divCustomerContactNametag" style="float: left; padding-left: 10px">
										<p class="text-muted">$!{customerContact.cname}</p>
									</span>
									<span id = "divCustomerContactNameurl" style="float: left; padding-left: 10px">
										<p class="text-muted"><a href="#" onclick="findAdminContact('$!{customId}')">获取联系人</a></p>
									</span>
									<span class="clearfix"> </span> 
									<span style="float: left; padding-left: 50px">座机:</span> 
									<span style="float: left; padding-left: 10px">
										<p class="text-muted">&nbsp;$!{customerContact.phone}</p>
									</span> 
									<span class="clearfix"></span> 
									<span style="float: left; padding-left: 50px">备注:</span> 
									<span style="float: left; padding-left: 10px">
										<p class="text-muted">&nbsp;$!{customerContact.remark}</p>
									</span> 
									<span class="clearfix"></span>
									<input type="hidden" id = "customerContactName"  value = "$!{customerContact.cname}"/>
								</div>
								<!-- 会员基本信息标签页 结束 -->
								
								
							</div>
						</div>
					</div>
				</div>

				<div id="tabs-2" class="col-xs-12">
					<table id="grid-table2"></table>

					<div id="grid-pager2"></div>
				</div>

				<div id="tabs-3" class="col-xs-12">
					<table id="grid-table3"></table>

					<div id="grid-pager3"></div>
				</div>
				<div id="tabs-4" class="col-xs-12">
					<table id="grid-table4"></table>
					<div >
					<a href="#communicationPopup" role="button" class="btn"  data-toggle="modal">添加沟通记录</a>
					</div>
					<div id="grid-pager4"></div>
					
				</div>
				<div id="tabs-5" class="col-xs-12">
					<table id="grid-table5"></table>

					<div id="grid-pager5"></div>
				</div>
				
				
			</div>
		</div>
	</div>

	<!-- 添加沟通记录弹出框 -->

	<div id="communicationPopup" class="modal fade" tabindex="-1">
		<div class="modal-dialog" style="width: 800px;">
			<div class="modal-content">
				<div class="modal-body">
					<form id="validation-form" method="post" action="${rc.contextPath}/serviceManage/addCommunicationRecord">
						<table class="table table-condensed">
							<tr>
								<td>联系人：</td>
								<td><input name="customerName" type="text"></input></td>
							</tr>
							<tr>
								<td>联系电话</td>
								<td><input name="customerPhone" type="text"></input></td>
							</tr>
							<tr>
								<td>沟通方式：</td>
								<td><select name='concatModel'>
										<option>请选择</option>
										<option value="电话沟通">电话沟通</option>
										<option value="QQ">QQ</option>
										<option value="邮件">邮件</option>
										<option value="外出拜访">外出拜访</option>
										<option value="公司会见">公司会见</option>
								</select></td>
							</tr>
							<tr>
								<td>沟通内容：</td>
								<td><textarea name="explain"></textarea></td>
							</tr>
							<tr>
								<td>是否有意向：</td>
								<td><select id="communicationMind"
									onchange="communicationMind()">
										<option value="1">是</option>
										<option value="0">否</option>
								</select></td>
							</tr>
							<tr>
								<td>销售进程：</td>
								<td><select name="consumePhase">
										<option value="需求待确定">需求待确定</option>
										<option value="需求确定">需求确定</option>
										<option value="等待付款">等待付款</option>
										<option value="交易完成">交易完成</option>
										<option value="输单">输单</option>
								</select></td>
							</tr>
							<tr>
								<td>意向产品：</td>
								<td><input type="checkbox" name="product" value="V">虚机</input> 
									<input type="checkbox" name="product" value="CHIYUN">驰云服务器</input> 
									<input type="checkbox" name="product" value="NYZJ">云服务器</input> 
									<input type="checkbox" name="product" value="ZJZY">主机租用托管</input>
									<input type="checkbox" name="product" value="M">企业邮箱</input> 
									<input type="checkbox" name="product" value="NOFC">新办公</input> 
									<input type="checkbox" name="product" value="COLUDPUSH">云推送</input></td>
							</tr>
							<tr>
								<td>预计消耗日期：</td>
								<td><input type="text" value="2016-10-12 15:05" name="date"
									id="datetimepicker"></td>
							</tr>
							<tr>
								<td>预计消耗金额：</td>
								<td><input name="amount" type="text"></input></td>
							</tr>
							<tr>
								<td>计划联系日期：</td>
								<td><input name="nextContactDate" type="text"></input></td>
							</tr>

						</table>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					<button type="submit" class="btn btn-primary">确定</button>
				</div>
				<input type="hidden" name="cusId" value="$!{customId}"/>
				</form>
			</div>
		</div>

	</div>
	<!-- 添加沟通记录弹出框   结束-->
	<script type="text/javascript">
		try{ace.settings.check('sidebar' , 'collapsed')}catch(e){}
	</script>
	<script type="text/javascript">
		var grid_selector = "#grid-table1";
		var pager_selector = "#grid-pager1";
		
		$('#datetimepicker').datetimepicker({
			   minView: "month", //选择日期后，不会再跳转去选择时分秒 
			　　format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式 
			　　language: 'zh-CN', //汉化 
			　　autoclose:true //选择日期后自动关闭 
		});
		
		//switch element when editing inline
		function aceSwitch( cellvalue, options, cell ) {
			setTimeout(function(){
				$(cell) .find('input[type=checkbox]')
						.wrap('<label class="inline" />')
					.addClass('ace ace-switch ace-switch-5')
					.after('<span class="lbl"></span>');
			}, 0);
		}
		//enable datepicker
		function pickDate( cellvalue, options, cell ) {
			setTimeout(function(){
				$(cell) .find('input[type=text]')
						.datepicker({format:'yyyy-mm-dd' , autoclose:true}); 
			}, 0);
		}
		function style_edit_form(form) {
			//enable datepicker on "sdate" field and switches for "stock" field
			form.find('input[name=sdate]').datepicker({format:'yyyy-mm-dd' , autoclose:true})
				.end().find('input[name=stock]')
					  .addClass('ace ace-switch ace-switch-5').wrap('<label class="inline" />').after('<span class="lbl"></span>');
	
			//update buttons classes
			var buttons = form.next().find('.EditButton .fm-button');
			buttons.addClass('btn btn-sm').find('[class*="-icon"]').remove();//ui-icon, s-icon
			buttons.eq(0).addClass('btn-primary').prepend('<i class="icon-ok"></i>');
			buttons.eq(1).prepend('<i class="icon-remove"></i>')
			
			buttons = form.next().find('.navButton a');
			buttons.find('.ui-icon').remove();
			buttons.eq(0).append('<i class="icon-chevron-left"></i>');
			buttons.eq(1).append('<i class="icon-chevron-right"></i>');		
		}
	
		function style_delete_form(form) {
			var buttons = form.next().find('.EditButton .fm-button');
			buttons.addClass('btn btn-sm').find('[class*="-icon"]').remove();//ui-icon, s-icon
			buttons.eq(0).addClass('btn-danger').prepend('<i class="icon-trash"></i>');
			buttons.eq(1).prepend('<i class="icon-remove"></i>')
		}
		
		function style_search_filters(form) {
			form.find('.delete-rule').val('X');
			form.find('.add-rule').addClass('btn btn-xs btn-primary');
			form.find('.add-group').addClass('btn btn-xs btn-success');
			form.find('.delete-group').addClass('btn btn-xs btn-danger');
		}
		function style_search_form(form) {
			var dialog = form.closest('.ui-jqdialog');
			var buttons = dialog.find('.EditTable')
			buttons.find('.EditButton a[id*="_reset"]').addClass('btn btn-sm btn-info').find('.ui-icon').attr('class', 'icon-retweet');
			buttons.find('.EditButton a[id*="_query"]').addClass('btn btn-sm btn-inverse').find('.ui-icon').attr('class', 'icon-comment-alt');
			buttons.find('.EditButton a[id*="_search"]').addClass('btn btn-sm btn-purple').find('.ui-icon').attr('class', 'icon-search');
		}
		
		function beforeDeleteCallback(e) {
			var form = $(e[0]);
			if(form.data('styled')) return false;
			
			form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
			style_delete_form(form);
			
			form.data('styled', true);
		}
		
		function beforeEditCallback(e) {
			var form = $(e[0]);
			form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
			style_edit_form(form);
		}
	
	
	
		//it causes some flicker when reloading or navigating grid
		//it may be possible to have some custom formatter to do this as the grid is being created to prevent this
		//or go back to default browser checkbox styles for the grid
		function styleCheckbox(table) {
		/**
			$(table).find('input:checkbox').addClass('ace')
			.wrap('<label />')
			.after('<span class="lbl align-top" />')
	
	
			$('.ui-jqgrid-labels th[id*="_cb"]:first-child')
			.find('input.cbox[type=checkbox]').addClass('ace')
			.wrap('<label />').after('<span class="lbl align-top" />');
		*/
		}
		
	
		//unlike navButtons icons, action icons in rows seem to be hard-coded
		//you can change them like this in here if you want
		function updateActionIcons(table) {
			/**
			var replacement = 
			{
				'ui-icon-pencil' : 'icon-pencil blue',
				'ui-icon-trash' : 'icon-trash red',
				'ui-icon-disk' : 'icon-ok green',
				'ui-icon-cancel' : 'icon-remove red'
			};
			$(table).find('.ui-pg-div span.ui-icon').each(function(){
				var icon = $(this);
				var $class = $.trim(icon.attr('class').replace('ui-icon', ''));
				if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]);
			})
			*/
		}
		
		//replace icons with FontAwesome icons like above
		function updatePagerIcons(table) {
			var replacement = 
			{
				'ui-icon-seek-first' : 'icon-double-angle-left bigger-140',
				'ui-icon-seek-prev' : 'icon-angle-left bigger-140',
				'ui-icon-seek-next' : 'icon-angle-right bigger-140',
				'ui-icon-seek-end' : 'icon-double-angle-right bigger-140'
			};
			$('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function(){
				var icon = $(this);
				var $class = $.trim(icon.attr('class').replace('ui-icon', ''));
				
				if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]);
			})
		}
	
		function enableTooltips(table) {
			$('.navtable .ui-pg-button').tooltip({container:'body'});
			$(table).find('.ui-pg-div').tooltip({container:'body'});
		}
		
		function makegrid(url,caption,column,data,postData){
			var widths=$("#tabs").width()-40;
			jQuery(grid_selector).jqGrid({
				url : url,
				postData:postData,
				mtype : "POST",
				contentType : "application/json",
				datatype : "json",
				height: 350,
				width:widths,
				colNames:column,
				colModel:data, 
				
				viewrecords : true,
				rowNum:10,
				rowList:[10,30,50],
				pager : pager_selector,
				emptyrecords: "没有查到相关数据！", 
				pgtext : "第{0}页，总共{1}页", 
				recordtext : "记录 {0} - {1} 总记录数 {2}",
				loadtext:"加载中，请稍候...",
				altRows: true,
				multiboxonly : true,
				jsonReader : {
				      root:"records",
				      page: "pageNow", //当前页
				      total: "pageCount", //总页数
				      records: "rowCount"//总记录数
				},
				loadComplete : function() {
					var table = this;
					$("#id").setGridWidth($(window).width()*0.98);　
					setTimeout(function(){
						styleCheckbox(table);
						updateActionIcons(table);
						updatePagerIcons(table);
						enableTooltips(table);
					}, 0);
				},
				editurl: '${ctx}/reports/ajaxEditReports',
				caption: caption,
			});
		}
		function makepager(url,caption,column,data,postData){
			var jqnav =  jQuery(grid_selector).jqGrid('navGrid',pager_selector,
					{ 	//navbar options
						edit: true,
						editicon : 'icon-pencil blue',
						add: true,
						addicon : 'icon-plus-sign purple',
						del: true,
						delicon : 'icon-trash red',
						search: true,
						searchicon : 'icon-search orange',
						refresh: true,
						refreshicon : 'icon-refresh green',
						view: true,
						viewicon : 'icon-zoom-in grey',
						searchtext:'    查找   ',edittext:'    编辑    ',addtext:'    添加    ',refreshtext:'    刷新    ', deltext:'    删除    ',viewtext:'    查看    ',
					},
					
					{
						//edit record form
						//closeAfterEdit: true,
						recreateForm: true,
					    editCaption: "编辑",
					    top:200,
					    left:600,
						beforeShowForm : function(e) {
							
							var form = $(e[0]);
							form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
							style_edit_form(form);
						}
					},
					{
						//new record form
						closeAfterAdd: true,
						recreateForm: true,
						editCaption: "新增",
						viewPagerButtons: false,
						beforeShowForm : function(e) {
							var form = $(e[0]);
							form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
							style_edit_form(form);
						}
					},
					{
						//delete record form
						recreateForm: true,
						beforeShowForm : function(e) {
							var form = $(e[0]);
							if(form.data('styled')) return false;
							
							form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
							style_delete_form(form);
							
							form.data('styled', true);
						},
						onClick : function(e) {
							alert(1);
						}
					},
					{
						//search form
						recreateForm: true,
						afterShowSearch: function(e){
							var form = $(e[0]);
							form.closest('.ui-jqdialog').find('.ui-jqdialog-title').wrap('<div class="widget-header" />')
							style_search_form(form);
						},
						afterRedraw: function(){
							style_search_filters($(this));
						}
						,
						multipleSearch: true,
						/**
						multipleGroup:true,
						showQuery: true
						*/
					},
					{
						//view record form
						recreateForm: true,
						beforeShowForm: function(e){
							var form = $(e[0]);
							form.closest('.ui-jqdialog').find('.ui-jqdialog-title').wrap('<div class="widget-header" />')
						}
					}
				)	
			jqnav.navButtonAdd(pager_selector, {
            caption: "调配",
            title:"调配",
            buttonicon: 'icon-share-alt purple',
            onClickButton: function () {
                var s;
               //多选获取
                s = jQuery(grid_selector).jqGrid('getGridParam', 'selarrrow');
                alert(s);
            },
            position: "last"
        })
        jqnav.navButtonAdd(pager_selector, {
            caption: "批量调配",
            title:"批量调配",
            buttonicon: 'icon-share ',
            onClickButton: function () {
                var s;
               //多选获取
                s = jQuery(grid_selector).jqGrid('getGridParam', 'selarrrow');
                alert(s);
            },
            position: "last"
        })
		}
		//这里以后可能会加编辑菜单
		
		
		//id,查询url,标题，字段，数据
		function createTable(id){
			
			var url="";
			var caption="";
			var column="";
			var data="";
			var postData="";
			if(id!=1){
				grid_selector = "#grid-table"+id;
				pager_selector = "#grid-pager"+id;
			} else {
				grid_selector = "#grid-table"+1;
				pager_selector = "#grid-pager"+1;
			}
			if(id==2){
				url="${rc.contextPath}/customerManage/queryBuyGoods";
				column='["服务编号","商品名称","域名或IP","购买时间","开通时间","到期时间"]';
				caption ="商品信息";
				data='[{"name":"serviceId"}, {"name":"goodsName"}, {"name":"domainName"}, {"name":"buyTime"}, {"name":"buyTime"}, {"name":"dueTime"}]';
				data = jQuery.parseJSON(data);
				column = jQuery.parseJSON(column);
				postData = jQuery.parseJSON('{"customId":"$!{customId}"}');
			}
			if(id==3){
				url="${rc.contextPath}/customerManage/queryOrderByCustomId";
				column='["订单编号","服务编号","商品名称","类型","订单价格","域名","订单日期","服务开始日期","服务到期日期","是否退费"]';
				caption ="订单信息";
				data='[{"name":"orderId","width":"200"}, {"name":"serviceId","width":"220"}, {"name":"goodsName"}, {"name":"orderType","width":"60"}, {"name":"goodsPrice","width":"80"}, {"name":"domainName","width":"200"}, {"name":"operateTime","width":"180"}, {"name":"buyTime"}, {"name":"dueTime"},{"name":"isReturns","width":"70"}]';
				data = jQuery.parseJSON(data);
				column = jQuery.parseJSON(column);
				postData = jQuery.parseJSON('{"customId":"$!{customId}"}');
			}
			if(id==4){
				url="${rc.contextPath}/customerManage/customerConsumeList";
				column='["客户联系人","沟通方式","联系电话","意向商品","预约下次交流时间","内容","沟通时间","销售人员"]';
				caption ="沟通记录";
				data='[{"name":"customerName"}, {"name":"concatModel"}, {"name":"customerPhone"}, {"name":"product"}, {"name":"nextContactDate"}, {"name":"explain"},{"name":"updateTime"},{"name":"ename"}]';
				data = jQuery.parseJSON(data);
				column = jQuery.parseJSON(column);
				postData = jQuery.parseJSON('{"cusId":"$!{customId}"}');
			}
			if(id==5){
				url="${rc.contextPath}/cart/showShopCart";
				column='["会员号","商品名称","商品内容","方式","年限","操作时间"]';
				caption ="购物车信息";
				data='[{"name":"agentCode","width":"100"}, {"name":"goodsName"}, {"name":"productContent"}, {"name":"purchaseCategory","width":"100"}, {"name":"purchaseTime"},{"name":"operateTime"} ]';
				data = jQuery.parseJSON(data);
				column = jQuery.parseJSON(column);
				postData = jQuery.parseJSON('{"agentCode":"$!{customId}"}');
			}
			makegrid(url,caption,column,data,postData);
		}
		
		jQuery(function($) {
			$("#tabs").tabs();
			$("#tabs2").tabs();
			/* makegrid();
			makepage(); */
			$('#skip-validation').removeAttr('checked').on('click', function(){
				$validation = this.checked;
				if(this.checked) {
					$('#sample-form').hide();
					$('#validation-form').removeClass('hide');
				}
				else {
					$('#validation-form').addClass('hide');
					$('#sample-form').show();
				}
			});
		});
		$('#validation-form').validate(
				{
					errorElement : 'div',
					errorClass : 'help-block',
					focusInvalid : false,
					rules : {
						bType : {
							required : true
						},
						uname : {
							required : true,
							minlength : 6
						},
						taskDescribe : {
							required : true,
							minlength : 5
						},
						reportSql : {
							required : true
						},
						quartzTime : {
							required : true								
						},
						dataBase : {
							required : true
						}
					},
					messages : {
						reportName : {
							required : "该字段不能为空！",
							minlength:"请输入最少10个字符！"
						},
						bType : {
							required : "请选择一个类型！"
						},
						taskDescribe : {
							required : "该字段不能为空！",
							minlength:"请输入最少10个字符！"
						},
						reportSql : {
							required : "该字段不能为空！"
						},
						quartzTime : {
							required : "该字段不能为空！"
						},
						
						dataBase : {
							required : "请选择一个类型！"
						}
					},

					invalidHandler : function(event, validator) { //display error alert on form submit   
						$('.alert-danger', $('.login-form')).show();
					},

					highlight : function(e) {
						$(e).closest('.form-group').removeClass(
								'has-info').addClass('has-error');
					},

					success : function(e) {
						$(e).closest('.form-group').removeClass(
								'has-error').addClass('has-info');
						$(e).remove();
					},

					errorPlacement : function(error, element) {
						if (element.is(':checkbox')
								|| element.is(':radio')) {
							var controls = element
									.closest('div[class*="col-"]');
							if (controls.find(':checkbox,:radio').length > 1)
								controls.append(error);
							else
								error.insertAfter(element.nextAll(
										'.lbl:eq(0)').eq(0));
						} else if (element.is('.select2')) {
							error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
						} else if (element.is('.chosen-select')) {
							error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
						} else
							error.insertAfter(element.parent());
					},
					submitHandler : function(form) {
						/* deleteConfirmPop("是否提交","是否确认删除，删除后可能会造成影响",function(){
							//表单提交，不加这个将无法提交验证成功后的表单
							form.submit();  
						}); 
						
						messagePop("友情提示","请先填写某某字段"); 
						
						submitConfirmPop("是否提交","是否确认提交？",function(){
							//表单提交，不加这个将无法提交验证成功后的表单
							form.submit();  
						});  */
						
						bootbox.confirm("确认提交？", function(result) {
							if(result) {
								var uname=$("#uname").val();
								var cNature=$("#cNature").val();
								var address=$("#address").val();
								var email=$("#email").val();
								var mobile=$("#mobile").val();
								var phone=$("#phone").val();
								var cname=$("#cname").val();
								var remark=$("#remark").val();
								$.ajax({
									type:"post",
									data: {
										"cusId":'$!{customId}',
										"uname":uname,
										"cname":cname,
										"cNature": cNature,
										"address": address,
										"email": email,
										"phone": phone,
										"mobile": mobile,
										"remark": remark
									},    //参数值
									dataType:"text",
									url:'${rc.contextPath}/contact/addContact',
									success:function(msg) {
										messagePop("友情提示",msg); 
										history.go(0);
									}
								});
								/* form.submit();   */
							}
						}); 
					},
					invalidHandler : function(form) {
					}
				});
		function refreshBalance(){
			$.ajax({
				type:"GET",
				dataType:"text",
				url:'${rc.contextPath}/customerManage/getCustomerBalance?customId=$!{customId}',
				success:function(msg) {
					$("#balance").text(msg);
				}
			});
		}
		
		jQuery(function($) {
			var customerContactName = $('#customerContactName').val();
			if(customerContactName==""){
				$('#divCustomerContactNametag').hide();
				$('#divCustomerContactNameurl').show();
			}else{
				$('#divCustomerContactNametag').show();
				$('#divCustomerContactNameurl').hide();
			}
		});
		
		
	 
	</script>
</body>
</html>
